package com.software.controller;

import com.software.dao.InvoiceDAO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/updateState")
public class UpdateState extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取要作废的发票ID
        int invoiceNumber = Integer.parseInt(request.getParameter("invoiceNumber"));

        // 调用DAO层方法更新发票状态为作废
        InvoiceDAO.cancelInvoice(invoiceNumber);

        // 重定向到展示发票信息的页面
        response.sendRedirect("SearchInvoice.jsp");


    }
}
